#include <iostream>
#include <vector>
#include <algorithm>
#include <thread>

using namespace std;

struct Goods
{
	string _name;  //名字
	double _price; //价格
	int _num;      //数量
};

struct ComparePriceLess{
    bool operator()(const Goods& g1, const Goods& g2){
        return g1._price < g2._price;
    }
};

struct CompareNumLess{
    bool operator()(const Goods& g1, const Goods& g2){
        return g1._num < g2._num;
    }
};

void Print(const vector<Goods>& v){
    for(const auto& g : v){
        cout << "商品名：" << g._name << ",价格：" << g._price << ",数量：" << g._num << endl;
    }
}

void test1(){
    vector<Goods> v = { { "苹果", 2.1, 300 }, { "香蕉", 3.3, 100 }, { "橙子", 2.2, 1000 }, { "菠萝", 1.5, 1 } };
    sort(v.begin(), v.end(), ComparePriceLess());
    Print(v);
    sort(v.begin(), v.end(), CompareNumLess());
    Print(v);
}

void test2(){
    vector<Goods> v = { { "苹果", 2.1, 300 }, { "香蕉", 3.3, 100 }, { "橙子", 2.2, 1000 }, { "菠萝", 1.5, 1 } };
    sort(v.begin(), v.end(), [](const Goods& g1, const Goods& g2){
        return g1._price < g2._price;
    });
    Print(v);

    sort(v.begin(), v.end(), [](const Goods& g1, const Goods& g2){
        return g1._num < g2._num;
    });
    Print(v);
}

/*
int main() {
    test2();
    return 0;
}
*/

void func(int n, int id){
    for (int i = 0; i < n; ++i) {
        cout << id << ":" << i << endl;
    }
    cout << endl;
}

void test3(){
    int n1, n2;
    cin >> n1 >> n2;
    thread t1(func, n1, 1);
    thread t2(func, n2, 2);

    t1.join();
    t2.join();
}

void test4(){
    int n1, n2;
    cin >> n1 >> n2;
    thread t1([n1](int id){
        for (int i = 0; i < n1; ++i) {
            cout << id << ":" << i << endl;
        }
        cout << endl;
    }, 1);
    thread t2([n2](int id){
        for (int i = 0; i < n2; ++i) {
            cout << id << ":" << i << endl;
        }
        cout << endl;
    }, 2);
    t1.join();
    t2.join();
}

void test5(){
    int m;
    cin >> m;
    vector<thread> vt(m);

    for (int i = 0; i < m; ++i) {
        size_t n;
        cin >> n;
        vt[i] = thread([i, n](){
            for (int j = 0; j < n; ++j) {
                cout << i << ":" << j << endl;
            }
            cout << endl;
        });
    }
    for (auto& t : vt) {
        t.join();
    }
}

void test6(){
    int m = 3;
    vector<thread> vt(m);

    for (int i = 0; i < m; ++i) {
        size_t n = 6;
        vt[i] = thread([i, n](){
            for (int j = 0; j < n; ++j) {
                cout << this_thread::get_id() << ":" << j << endl;
                this_thread::sleep_for(chrono::seconds(1));
            }
            cout << endl;
        });
    }
    for (auto& t : vt) {
        t.join();
    }
}

int main(){
    test6();
    return 0;
}